package NIO.Channel通道;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

public class Example22 {
    public static void main(String[] args) throws IOException {
        RandomAccessFile infile = new RandomAccessFile("src/IO流/NIO/Channel通道/time.txt", "rw");
        FileChannel inChannel = infile.getChannel();
        RandomAccessFile outfile = new RandomAccessFile("src/IO流/NIO/Channel通道/timecheck.txt", "rw");
        FileChannel outchannel = outfile.getChannel();
//      使用transferTo()方法进行写入操作
        long transferTo=inChannel.transferTo(0,inChannel.size(),outchannel);
        if (transferTo>=0){
            System.out.println("操作成功");
        }
        infile.close();
        outfile.close();
        inChannel.close();
        outchannel.close();

    }


}
